import excel "${datadir_el}\171115 HCA redemptions data.xlsx", ///
	sheet("redemptions") firstrow clear

rename ID schemeid
drop if mi(schemeid)


merge 1:1 schemeid using ///
	"${datadir}\HCA_full.dta", keep(1 3)	///
	keepusing(schemeid) gen(mergefull)


merge 1:m schemeid using "${datadir}\HTB_main", ///
	keep(1 3) gen(merge_htb_main) ///
	keepusing(schemeid dealtype appreciation2 ///
	LTV  LTV_round combined_LTV ///
	LTI_original combined_LTI ///
	htb_london lender_id psd_id ///
	loan_final interest00 date payment)
	
save "${datadir}\HCA_redemptions_all", replace


preserve
	keep if Transactiontype == "Sale"
	save "${datadir}\HCA_redemptions_sale", replace
restore


keep if regexm(Transactiontype, "staircasing")
save "${datadir}\HCA_redemptions", replace

